//
//  SHKPageTable.m
//  EagleCloud
//
//  Created by Cer on 2019/8/7.
//
//

#import "YsNoteSDKPageTable.h"

@implementation YsNoteSDKPageTable
// 设置主键
+ (NSString *)primaryKey{
    return @"pageTableID";
}

- (int)incrementaID {    
    NSArray *resultArray =  [[YsRealmToolsManager queryAllObj:YsNoteSDKPageTable.class] sortedArrayUsingComparator:^NSComparisonResult(YsNoteSDKPageTable *obj1, YsNoteSDKPageTable *obj2) {
        //此处的规则含义为：若前一元素比后一元素小，则返回降序（即后一元素在前，为从大到小排列）
        if (obj2.pageTableID  < obj1.pageTableID){
            return NSOrderedDescending;
        }else{
            return NSOrderedAscending;
        }
    }];
    
    if (resultArray.count != 0) {
        YsNoteSDKPageTable *pageTable = resultArray.lastObject;
        return (int)(pageTable.pageTableID + 1);
    }else {
        return 0;
    }
}

@end
